﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.BLL;
using FJERP.Model;

namespace FJERP
{
    public partial class SupplierShow : System.Web.UI.Page
    {
        SupplierBLL bll = new SupplierBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                this.Repeater1.DataSource = bll.ShowSupplier();//获取数据
                this.Repeater1.DataBind();//绑定数据
                Label1.Text = bll.CountSupplier().ToString();//总记录数
            }
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string name = e.CommandName;
            string supid = e.CommandArgument.ToString();
            switch(name)
            {
                case "Del":
                    if(bll.Del( Convert.ToInt32(supid))>0)
                    {
                        Response.Write("<script>alert('删除成功!!!')</script>");
                        this.Repeater1.DataSource = bll.ShowSupplier();//获取数据
                        this.Repeater1.DataBind();//绑定数据
                        Label1.Text = bll.CountSupplier().ToString();//总记录数
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败!!!')</script>");
                    }
                    break;
                case "Upt":
                    Response.Redirect("SupplierEdit.aspx?id=" + supid);
                    break;
            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            string Supplier_Name = this.Supplier_Name.Value;
            this.Repeater1.DataSource = bll.ShowSupplier_Sel(Supplier_Name);//获取数据
            this.Repeater1.DataBind();//绑定数据
        }
    }
}